3.1.92 \(\int \frac {A+B \cot (c+d x)}{a+b \cot (c+d x)} \, dx\) [92]

Optimal. Leaf size=59 \[ \frac {(a A+b B) x}{a^2+b^2}-\frac {(A b-a B) \log (b \cos (c+d x)+a \sin (c+d x))}{\left (a^2+b^2\right ) d} \]

[Out]

(A*a+B*b)*x/(a^2+b^2)-(A*b-B*a)*ln(b*cos(d*x+c)+a*sin(d*x+c))/(a^2+b^2)/d

________________________________________________________________________________________

Rubi [A]
time = 0.06, antiderivative size = 59, normalized size of antiderivative = 1.00, number of steps used = 2, number of rules used = 2, integrand size = 23, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.087, Rules used = {3612, 3611} \begin {gather*} \frac {x (a A+b B)}{a^2+b^2}-\frac {(A b-a B) \log (a \sin (c+d x)+b \cos (c+d x))}{d \left (a^2+b^2\right )} \end {gather*}

Antiderivative was successfully verified.

[In]

Int[(A + B*Cot[c + d*x])/(a + b*Cot[c + d*x]),x]

[Out]

((a*A + b*B)*x)/(a^2 + b^2) - ((A*b - a*B)*Log[b*Cos[c + d*x] + a*Sin[c + d*x]])/((a^2 + b^2)*d)

Rule 3611

Int[((c_) + (d_.)*tan[(e_.) + (f_.)*(x_)])/((a_) + (b_.)*tan[(e_.) + (f_.)*(x_)]), x_Symbol] :> Simp[(c/(b*f))
*Log[RemoveContent[a*Cos[e + f*x] + b*Sin[e + f*x], x]], x] /; FreeQ[{a, b, c, d, e, f}, x] && NeQ[b*c - a*d,
0] && NeQ[a^2 + b^2, 0] && EqQ[a*c + b*d, 0]

Rule 3612

Int[((c_.) + (d_.)*tan[(e_.) + (f_.)*(x_)])/((a_.) + (b_.)*tan[(e_.) + (f_.)*(x_)]), x_Symbol] :> Simp[(a*c +
b*d)*(x/(a^2 + b^2)), x] + Dist[(b*c - a*d)/(a^2 + b^2), Int[(b - a*Tan[e + f*x])/(a + b*Tan[e + f*x]), x], x]
 /; FreeQ[{a, b, c, d, e, f}, x] && NeQ[b*c - a*d, 0] && NeQ[a^2 + b^2, 0] && NeQ[a*c + b*d, 0]

Rubi steps

\begin {align*} \int \frac {A+B \cot (c+d x)}{a+b \cot (c+d x)} \, dx &=\frac {(a A+b B) x}{a^2+b^2}-\frac {(A b-a B) \int \frac {-b+a \cot (c+d x)}{a+b \cot (c+d x)} \, dx}{a^2+b^2}\\ &=\frac {(a A+b B) x}{a^2+b^2}-\frac {(A b-a B) \log (b \cos (c+d x)+a \sin (c+d x))}{\left (a^2+b^2\right ) d}\\ \end {align*}

________________________________________________________________________________________

Mathematica [A]
time = 0.14, size = 67, normalized size = 1.14 \begin {gather*} -\frac {2 (a A+b B) \text {ArcTan}(\cot (c+d x))+(A b-a B) \left (2 \log (a+b \cot (c+d x))-\log \left (\csc ^2(c+d x)\right )\right )}{2 \left (a^2+b^2\right ) d} \end {gather*}

Antiderivative was successfully verified.

[In]

Integrate[(A + B*Cot[c + d*x])/(a + b*Cot[c + d*x]),x]

[Out]

-1/2*(2*(a*A + b*B)*ArcTan[Cot[c + d*x]] + (A*b - a*B)*(2*Log[a + b*Cot[c + d*x]] - Log[Csc[c + d*x]^2]))/((a^
2 + b^2)*d)

________________________________________________________________________________________

Maple [A]
time = 0.29, size = 91, normalized size = 1.54

method result size
norman \(\frac {\left (A a +B b \right ) x}{a^{2}+b^{2}}+\frac {\left (A b -B a \right ) \ln \left (1+\tan ^{2}\left (d x +c \right )\right )}{2 d \left (a^{2}+b^{2}\right )}-\frac {\left (A b -B a \right ) \ln \left (a \tan \left (d x +c \right )+b \right )}{d \left (a^{2}+b^{2}\right )}\) \(86\)
derivativedivides \(\frac {-\frac {\left (A b -B a \right ) \ln \left (a +b \cot \left (d x +c \right )\right )}{a^{2}+b^{2}}+\frac {\frac {\left (A b -B a \right ) \ln \left (\cot ^{2}\left (d x +c \right )+1\right )}{2}+\left (-A a -B b \right ) \left (\frac {\pi }{2}-\mathrm {arccot}\left (\cot \left (d x +c \right )\right )\right )}{a^{2}+b^{2}}}{d}\) \(91\)
default \(\frac {-\frac {\left (A b -B a \right ) \ln \left (a +b \cot \left (d x +c \right )\right )}{a^{2}+b^{2}}+\frac {\frac {\left (A b -B a \right ) \ln \left (\cot ^{2}\left (d x +c \right )+1\right )}{2}+\left (-A a -B b \right ) \left (\frac {\pi }{2}-\mathrm {arccot}\left (\cot \left (d x +c \right )\right )\right )}{a^{2}+b^{2}}}{d}\) \(91\)
risch \(\frac {i x B}{i b +a}+\frac {x A}{i b +a}+\frac {2 i A b x}{a^{2}+b^{2}}-\frac {2 i B a x}{a^{2}+b^{2}}+\frac {2 i A b c}{d \left (a^{2}+b^{2}\right )}-\frac {2 i B a c}{d \left (a^{2}+b^{2}\right )}-\frac {\ln \left ({\mathrm e}^{2 i \left (d x +c \right )}+\frac {i b -a}{i b +a}\right ) A b}{d \left (a^{2}+b^{2}\right )}+\frac {\ln \left ({\mathrm e}^{2 i \left (d x +c \right )}+\frac {i b -a}{i b +a}\right ) B a}{d \left (a^{2}+b^{2}\right )}\) \(179\)

Verification of antiderivative is not currently implemented for this CAS.

[In]

int((A+B*cot(d*x+c))/(a+b*cot(d*x+c)),x,method=_RETURNVERBOSE)

[Out]

1/d*(-(A*b-B*a)/(a^2+b^2)*ln(a+b*cot(d*x+c))+1/(a^2+b^2)*(1/2*(A*b-B*a)*ln(cot(d*x+c)^2+1)+(-A*a-B*b)*(1/2*Pi-
arccot(cot(d*x+c)))))

________________________________________________________________________________________

Maxima [A]
time = 0.54, size = 89, normalized size = 1.51 \begin {gather*} \frac {\frac {2 \, {\left (A a + B b\right )} {\left (d x + c\right )}}{a^{2} + b^{2}} + \frac {2 \, {\left (B a - A b\right )} \log \left (a \tan \left (d x + c\right ) + b\right )}{a^{2} + b^{2}} - \frac {{\left (B a - A b\right )} \log \left (\tan \left (d x + c\right )^{2} + 1\right )}{a^{2} + b^{2}}}{2 \, d} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((A+B*cot(d*x+c))/(a+b*cot(d*x+c)),x, algorithm="maxima")

[Out]

1/2*(2*(A*a + B*b)*(d*x + c)/(a^2 + b^2) + 2*(B*a - A*b)*log(a*tan(d*x + c) + b)/(a^2 + b^2) - (B*a - A*b)*log
(tan(d*x + c)^2 + 1)/(a^2 + b^2))/d

________________________________________________________________________________________

Fricas [A]
time = 2.69, size = 79, normalized size = 1.34 \begin {gather*} \frac {2 \, {\left (A a + B b\right )} d x + {\left (B a - A b\right )} \log \left (a b \sin \left (2 \, d x + 2 \, c\right ) + \frac {1}{2} \, a^{2} + \frac {1}{2} \, b^{2} - \frac {1}{2} \, {\left (a^{2} - b^{2}\right )} \cos \left (2 \, d x + 2 \, c\right )\right )}{2 \, {\left (a^{2} + b^{2}\right )} d} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((A+B*cot(d*x+c))/(a+b*cot(d*x+c)),x, algorithm="fricas")

[Out]

1/2*(2*(A*a + B*b)*d*x + (B*a - A*b)*log(a*b*sin(2*d*x + 2*c) + 1/2*a^2 + 1/2*b^2 - 1/2*(a^2 - b^2)*cos(2*d*x
+ 2*c)))/((a^2 + b^2)*d)

________________________________________________________________________________________

Sympy [C] Result contains complex when optimal does not.
time = 0.48, size = 524, normalized size = 8.88 \begin {gather*} \begin {cases} \frac {\tilde {\infty } x \left (A + B \cot {\left (c \right )}\right )}{\cot {\left (c \right )}} & \text {for}\: a = 0 \wedge b = 0 \wedge d = 0 \\\frac {i A d x \cot {\left (c + d x \right )}}{2 b d \cot {\left (c + d x \right )} - 2 i b d} + \frac {A d x}{2 b d \cot {\left (c + d x \right )} - 2 i b d} - \frac {i A}{2 b d \cot {\left (c + d x \right )} - 2 i b d} + \frac {B d x \cot {\left (c + d x \right )}}{2 b d \cot {\left (c + d x \right )} - 2 i b d} - \frac {i B d x}{2 b d \cot {\left (c + d x \right )} - 2 i b d} + \frac {B}{2 b d \cot {\left (c + d x \right )} - 2 i b d} & \text {for}\: a = - i b \\- \frac {i A d x \cot {\left (c + d x \right )}}{2 b d \cot {\left (c + d x \right )} + 2 i b d} + \frac {A d x}{2 b d \cot {\left (c + d x \right )} + 2 i b d} + \frac {i A}{2 b d \cot {\left (c + d x \right )} + 2 i b d} + \frac {B d x \cot {\left (c + d x \right )}}{2 b d \cot {\left (c + d x \right )} + 2 i b d} + \frac {i B d x}{2 b d \cot {\left (c + d x \right )} + 2 i b d} + \frac {B}{2 b d \cot {\left (c + d x \right )} + 2 i b d} & \text {for}\: a = i b \\\frac {x \left (A + B \cot {\left (c \right )}\right )}{a + b \cot {\left (c \right )}} & \text {for}\: d = 0 \\\frac {\frac {A \log {\left (\tan ^{2}{\left (c + d x \right )} + 1 \right )}}{2 d} + B x}{b} & \text {for}\: a = 0 \\\frac {2 A a d x}{2 a^{2} d + 2 b^{2} d} - \frac {2 A b \log {\left (\tan {\left (c + d x \right )} + \frac {b}{a} \right )}}{2 a^{2} d + 2 b^{2} d} + \frac {A b \log {\left (\tan ^{2}{\left (c + d x \right )} + 1 \right )}}{2 a^{2} d + 2 b^{2} d} + \frac {2 B a \log {\left (\tan {\left (c + d x \right )} + \frac {b}{a} \right )}}{2 a^{2} d + 2 b^{2} d} - \frac {B a \log {\left (\tan ^{2}{\left (c + d x \right )} + 1 \right )}}{2 a^{2} d + 2 b^{2} d} + \frac {2 B b d x}{2 a^{2} d + 2 b^{2} d} & \text {otherwise} \end {cases} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((A+B*cot(d*x+c))/(a+b*cot(d*x+c)),x)

[Out]

Piecewise((zoo*x*(A + B*cot(c))/cot(c), Eq(a, 0) & Eq(b, 0) & Eq(d, 0)), (I*A*d*x*cot(c + d*x)/(2*b*d*cot(c +
d*x) - 2*I*b*d) + A*d*x/(2*b*d*cot(c + d*x) - 2*I*b*d) - I*A/(2*b*d*cot(c + d*x) - 2*I*b*d) + B*d*x*cot(c + d*
x)/(2*b*d*cot(c + d*x) - 2*I*b*d) - I*B*d*x/(2*b*d*cot(c + d*x) - 2*I*b*d) + B/(2*b*d*cot(c + d*x) - 2*I*b*d),
 Eq(a, -I*b)), (-I*A*d*x*cot(c + d*x)/(2*b*d*cot(c + d*x) + 2*I*b*d) + A*d*x/(2*b*d*cot(c + d*x) + 2*I*b*d) +
I*A/(2*b*d*cot(c + d*x) + 2*I*b*d) + B*d*x*cot(c + d*x)/(2*b*d*cot(c + d*x) + 2*I*b*d) + I*B*d*x/(2*b*d*cot(c
+ d*x) + 2*I*b*d) + B/(2*b*d*cot(c + d*x) + 2*I*b*d), Eq(a, I*b)), (x*(A + B*cot(c))/(a + b*cot(c)), Eq(d, 0))
, ((A*log(tan(c + d*x)**2 + 1)/(2*d) + B*x)/b, Eq(a, 0)), (2*A*a*d*x/(2*a**2*d + 2*b**2*d) - 2*A*b*log(tan(c +
 d*x) + b/a)/(2*a**2*d + 2*b**2*d) + A*b*log(tan(c + d*x)**2 + 1)/(2*a**2*d + 2*b**2*d) + 2*B*a*log(tan(c + d*
x) + b/a)/(2*a**2*d + 2*b**2*d) - B*a*log(tan(c + d*x)**2 + 1)/(2*a**2*d + 2*b**2*d) + 2*B*b*d*x/(2*a**2*d + 2
*b**2*d), True))

________________________________________________________________________________________

Giac [A]
time = 0.47, size = 95, normalized size = 1.61 \begin {gather*} \frac {\frac {2 \, {\left (A a + B b\right )} {\left (d x + c\right )}}{a^{2} + b^{2}} - \frac {{\left (B a - A b\right )} \log \left (\tan \left (d x + c\right )^{2} + 1\right )}{a^{2} + b^{2}} + \frac {2 \, {\left (B a^{2} - A a b\right )} \log \left ({\left | a \tan \left (d x + c\right ) + b \right |}\right )}{a^{3} + a b^{2}}}{2 \, d} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((A+B*cot(d*x+c))/(a+b*cot(d*x+c)),x, algorithm="giac")

[Out]

1/2*(2*(A*a + B*b)*(d*x + c)/(a^2 + b^2) - (B*a - A*b)*log(tan(d*x + c)^2 + 1)/(a^2 + b^2) + 2*(B*a^2 - A*a*b)
*log(abs(a*tan(d*x + c) + b))/(a^3 + a*b^2))/d

________________________________________________________________________________________

Mupad [B]
time = 1.00, size = 155, normalized size = 2.63 \begin {gather*} \frac {A\,\ln \left (\mathrm {cot}\left (c+d\,x\right )+1{}\mathrm {i}\right )}{2\,\left (b\,d+a\,d\,1{}\mathrm {i}\right )}-\frac {B\,\ln \left (\mathrm {cot}\left (c+d\,x\right )+1{}\mathrm {i}\right )}{2\,\left (a\,d-b\,d\,1{}\mathrm {i}\right )}-\frac {A\,b\,\ln \left (a+b\,\mathrm {cot}\left (c+d\,x\right )\right )}{d\,\left (a^2+b^2\right )}+\frac {B\,a\,\ln \left (a+b\,\mathrm {cot}\left (c+d\,x\right )\right )}{d\,\left (a^2+b^2\right )}+\frac {A\,\ln \left (\mathrm {cot}\left (c+d\,x\right )-\mathrm {i}\right )\,1{}\mathrm {i}}{2\,\left (a\,d+b\,d\,1{}\mathrm {i}\right )}-\frac {B\,\ln \left (\mathrm {cot}\left (c+d\,x\right )-\mathrm {i}\right )\,1{}\mathrm {i}}{2\,\left (-b\,d+a\,d\,1{}\mathrm {i}\right )} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

int((A + B*cot(c + d*x))/(a + b*cot(c + d*x)),x)

[Out]

(A*log(cot(c + d*x) - 1i)*1i)/(2*(a*d + b*d*1i)) + (A*log(cot(c + d*x) + 1i))/(2*(a*d*1i + b*d)) - (B*log(cot(
c + d*x) + 1i))/(2*(a*d - b*d*1i)) - (B*log(cot(c + d*x) - 1i)*1i)/(2*(a*d*1i - b*d)) - (A*b*log(a + b*cot(c +
 d*x)))/(d*(a^2 + b^2)) + (B*a*log(a + b*cot(c + d*x)))/(d*(a^2 + b^2))

________________________________________________________________________________________